# Maintainer: psykose <alice@ayaya.dev>
pkgname=buildkit
pkgver=0.10.3
pkgrel=0
_commit=c8d25d9a103b70dc300a4fd55e7e576472284e31
pkgdesc="Concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit"
url="https://github.com/moby/buildkit"
arch="all"
license="Apache-2.0"
depends="containerd"
makedepends="go"
subpackages="$pkgname-doc $pkgname-openrc buildctl"
source="$pkgname-$pkgver.tar.gz::https://github.com/moby/buildkit/archive/refs/tags/v$pkgver.tar.gz
	buildkitd.initd
	buildkitd.confd
	"
options="!check" # needs to mount various things as root

export GOFLAGS="$GOFLAGS -modcacherw -trimpath"
export CGO_ENABLED=0

prepare() {
	default_prepare
	mkdir out
}

build() {
	go build -v \
		-ldflags="
		-X github.com/moby/buildkit/version.Version=$pkgver \
		-X github.com/moby/buildkit/version.Revision=$_commit \
		" \
		-o out \
		./cmd/...
}

package() {
	install -Dm755 ./out/* \
		-t "$pkgdir"/usr/bin
	install -Dm644 ./docs/* \
		-t "$pkgdir"/usr/share/doc/$pkgname
	install -Dm755 "$srcdir"/buildkitd.initd \
		"$pkgdir"/etc/init.d/buildkitd
	install -Dm644 "$srcdir"/buildkitd.confd \
		"$pkgdir"/etc/conf.d/buildkitd
}

buildctl() {
	pkgdesc="$pkgdesc (cli frontend)"
	amove usr/bin/buildctl
}

sha512sums="
2237d07f4d2096ced7d3d309b9310a36bacf3b9be660ade95ea055cce8efa8ac136dd4981f607ae0883e5ed5e5e362ee935382562e9b4335f00e82260f9b6700  buildkit-0.10.3.tar.gz
01007221e6aab7a9f9565b48d2a338b2a72508234c7874a4aeaf9fd9181a19ffebe6374560bbae0262b009643b1fb49fb51b0f8006540355ae0f42fbaad5dd59  buildkitd.initd
44efad35c5867266a84246cf49afd2c4d775a530409397c817c8026873c75686432388325cd7654d939e8bfeceeada9112f3dd814ae5d95d4470373c3aa6dc3e  buildkitd.confd
"
